<template>
	<view>
		<view class="topbg"></view>
		<!-- logo及大雪人会员 -->
		<view class="content">
			<!-- logo及大雪人会员内容 -->
			<view class="content-logo-snow">
				<view class="content-logo-snow-main">
					<!-- logo及签到 -->
					<view class="content-logo-snow-main-logo-qiandao">
						<view class="content-logo-snow-main-logo">
							<view class="content-logo-snow-main-logo-circle">
								<image class="content-logo-snow-main-logo-img"
									src="http://www.itlaobing.com/ice/other/wawa01.png"></image>
							</view>
							<view class="content-logo-snow-main-logo-account">
								135*****06
							</view>
						</view>
						<view class="content-logo-snow-main-qiandao" :class="myuser.isqQiandao==1?'qiandao-active':''"
							@click="qiandao">
							<uni-icons type="calendar-filled" size="20" color="#FFFFFF"></uni-icons>
							签到
						</view>
					</view>
					<!-- logo及签到 -->

					<!--  大雪人会员-->
					<view class="content-logo-snow-main-members">
						<view class="content-logo-snow-main-members-left">
							<view class="content-logo-snow-main-members-title">甜蜜雪人会员</view>
							<view class="content-logo-snow-main-members-text" style="padding-bottom: 10rpx;">
								甜蜜值：{{myuser.integral}}/1000</view>
							<progress :percent="myuser.integralVal" stroke-width="4" activeColor="#FFFFFF"
								border-radius="2" />
							<view class="content-logo-snow-main-members-text" style="padding-top: 20rpx;">
								再升1级可享【攒币加速】等9项权益</view>
						</view>
						<view class="content-logo-snow-main-members-right">
							<view>
								<image class="content-logo-snow-main-members-img"
									src="http://www.itlaobing.com/ice/other/wawa.png"></image>
							</view>
							<view class="content-logo-snow-main-members-text">查看权益<text decode="yes">&nbsp;&gt;</text>
							</view>
						</view>
					</view>
					<!--  大雪人会员-->
				</view>
			</view>
			<!-- logo及大雪人会员内容 -->

			<!-- 雪王币及优惠券 -->
			<view class="content-snowmoney-coupon">
				<!-- 雪王币 -->
				<view class="content-snowmoney-coupon-content">
					<view>
						<view class="content-snowmoney-coupon-value">
							{{myuser.snowmoney}}
						</view>
						<view class="content-snowmoney-coupon-name">
							雪王币
						</view>
					</view>
					<view>
						<image class="content-snowmoney-img"
							src="http://www.itlaobing.com/ice/other/qianbao.png"></image>
					</view>
				</view>
				<!-- 雪王币 -->

				<!-- 优惠券 -->
				<view class="content-snowmoney-coupon-content">
					<view>
						<view class="content-snowmoney-coupon-value">
							{{myuser.coupon}}
						</view>
						<view class="content-snowmoney-coupon-name">
							优惠券
						</view>
					</view>
					<view>
						<image class="content-snowmoney-img"
							src="http://www.itlaobing.com/ice/other/youhuiju.png"></image>
					</view>
				</view>
				<!-- 优惠券 -->
			</view>
			<!-- 雪王币及优惠券 -->

			<!-- 功能列表 -->
			<view class="content-list">
				<uni-list>
					<uni-list-item title="兑换码" show-extra-icon="true" :extra-icon="extraIcons[0]" showArrow>
					</uni-list-item>
					<uni-list-item title="隐私政策" show-extra-icon="true" :extra-icon="extraIcons[1]" showArrow>
					</uni-list-item>
					<uni-list-item title="用户服务协议" show-extra-icon="true" :extra-icon="extraIcons[2]" showArrow>
					</uni-list-item>
					<uni-list-item title="经营信息公示" show-extra-icon="true" :extra-icon="extraIcons[3]" showArrow>
					</uni-list-item>
				</uni-list>
			</view>
			<!-- 功能列表 -->
		</view>
		<!-- logo及大雪人会员 -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				myuser: {
					id: 20,
					icon: "http://www.itlaobing.com/ice/other/wawa01.png",
					username: '135****006',
					integral: 163, //甜蜜值
					integralVal: (163 / 1000) * 100, // 甜蜜值百分比
					snowmoney: 1837, //雪王币
					coupon: 0, //优惠劵
					isqQiandao: 0 //0.未签到 1已签到
				},
				extraIcons: [{
						color: '#F3C048',
						size: '22',
						type: 'gift'
					},
					{
						color: '#F3C048',
						size: '22',
						type: 'locked'
					},
					{
						color: '#F3C048',
						size: '22',
						type: 'wallet'
					},
					{
						color: '#F3C048',
						size: '22',
						type: 'images'
					}
				],
				wxcode: '',
				canIUseGetUserProfile: false,
				userInfo:{}
			}
		},
		onLoad() {
			//登录授权
			if (uni.getUserProfile) {
				this.canIUseGetUserProfile = true
			}
		},
		methods: {
			qiandao() {
				//0.未签到 1已签到
				if (this.myuser.isqQiandao == 0) { //如果0.未签到，执行签到
					this.myuser.isqQiandao = 1
					//雪王币+5
					this.myuser.snowmoney += 5
					// 后端记录签到状态
					//。。。。。。。。。。。
				}
			},
			//登录
			login() {
				let _this = this;
				// 获取登录用户code
				uni.login({
					provider: 'weixin',
					success: (res) => {
						console.log('res：', res)
						if (res.code) {
							_this.wxcode = res.code
							_this.getUserProfile()
						} else {
							uni.showToast({
								title: '微信登录失败！',
								duration: 2000
							});
						}
					},
				});
			},
			//登录授权
			getUserProfile() {
				var _this = this;
				uni.getUserProfile({
					desc: '登录',
					provider: 'weixin',
					success: (info) => {
						console.log('info：', info)
						this.userInfo = info
						try {
							uni.showLoading({
								title: '登录中...'
							});
							//请求后台，成功并隐藏加载
							uni.hideLoading({})
						} catch (e) {
							uni.showToast({
								title: "微信登录失败",
								icon: "none"
							});
						}
					},
					fail: (res) => {
						console.log("fail:" + res)
						uni.showToast({
							title: "您已取消授权",
							icon: "none"
						});
					}
				});
			},
			//微信登录状态监测
			checkLogin() {
				wx.checkSession({
					success() {
						console.log('ok');
					},
					fail() {
						//wx.login() // 重新登录
						console.log('expire');
					}
				})
			},
			//用户是否授权
			wxGetUserInfo(res) {
				if (!res.detail.iv) {
					uni.showToast({
						title: "您取消了授权,登录失败",
						icon: "none"
					});
					return false;
				}
				console.log(res.detail);
			},

		}
	}
</script>

<style lang="scss">
	.topbg {
		width: 100vw;
		height: 490rpx;
		background: linear-gradient(#FCF1E2 0%, #FEFAF3 100%);
		border-bottom-left-radius: 50rpx;
		border-bottom-right-radius: 50rpx;
	}

	.content {
		width: 92vw;
		margin: 0 auto;
	}

	.content-logo-snow {
		width: 100%;
		height: 195rpx;
		position: relative;

		.content-logo-snow-main {
			position: absolute;
			width: 100%;
			height: 480rpx;
			top: -310rpx;

			.content-logo-snow-main-logo-qiandao {
				width: 100%;
				height: 170rpx;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.content-logo-snow-main-logo {
					width: 400rpx;
					display: flex;
					justify-content: flex-start;
					align-items: center;

					.content-logo-snow-main-logo-circle {
						width: 140rpx;
						height: 140rpx;
						background-color: #FFFEF8;
						border-radius: 70rpx;
						display: flex;
						justify-content: center;
						align-items: center;
						margin-right: 10rpx;

						.content-logo-snow-main-logo-img {
							width: 90rpx;
							height: 90rpx;
						}
					}

					.content-logo-snow-main-logo-account {
						font-size: 34rpx;
						font-weight: bold;
						color: #777777;
					}
				}

				.content-logo-snow-main-qiandao {
					width: 130rpx;
					height: 56rpx;
					background: linear-gradient(#FF9FAE 10%, #FF5479 100%);
					border-radius: 28rpx;
					color: #FFFFFF;
					font-size: 24rpx;
					display: flex;
					align-items: center;
					justify-content: center;
				}

				.qiandao-active {
					background: #AAABBB;
				}
			}

			.content-logo-snow-main-members {
				width: 100%;
				height: 300rpx;
				background: linear-gradient(#FFD684, #F3C048);
				margin-top: 10rpx;
				border-radius: 15rpx;
				display: flex;
				padding: 50rpx 20rpx;
				box-sizing: border-box;
				justify-content: space-between;

				.content-logo-snow-main-members-left {
					width: 65%;
					height: 100%;

					.content-logo-snow-main-members-title {
						font-size: 42rpx;
						font-weight: bold;
						color: #FFFFFF;
						box-sizing: border-box;
						padding-bottom: 40rpx;
					}
				}

				.content-logo-snow-main-members-right {
					width: 33%;
					height: 100%;
					display: flex;
					flex-direction: column;
					justify-content: center;
					align-items: center;

					.content-logo-snow-main-members-img {
						width: 130rpx;
						height: 150rpx;
					}
				}

				.content-logo-snow-main-members-text {
					color: #FFFFFF;
					font-size: 26rpx;
				}
			}
		}
	}

	.content-snowmoney-coupon {
		width: 100%;
		height: 120rpx;
		display: flex;
		justify-content: space-between;

		.content-snowmoney-coupon-content {
			width: 48%;
			height: 100%;
			background-color: #FFFFFF;
			border-radius: 10rpx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			box-sizing: border-box;
			padding: 0 30rpx;

			.content-snowmoney-coupon-value {
				font-size: 32rpx;
				padding-bottom: 6rpx;
			}

			.content-snowmoney-coupon-name {
				font-size: 26rpx;
				color: #777777;
			}

			.content-snowmoney-img {
				width: 60rpx;
				height: 60rpx;
			}
		}
	}

	.content-list {
		width: 100%;
		margin-top: 25rpx;
	}
</style>
